package com.example.springbootshiro.response;

/**
 * 定义“业务异常”模型
 * <p>
 * Created by YangGang on 2019/03/24 16:54。
 */
public class BusinessError extends RuntimeException {
    private GlobalCodeEnum globalCodeEnum;

    public BusinessError(GlobalCodeEnum globalCodeEnum) {
        this.globalCodeEnum = globalCodeEnum;
    }

    public BusinessError(String message) {
        this.globalCodeEnum = GlobalCodeEnum.DEFAULT_ERROR;
        this.globalCodeEnum.setMessage(message);
    }

    @Override
    public String getMessage() {
        return this.globalCodeEnum.getMessage();
    }

    public GlobalCodeEnum getGlobalCodeEnum() {
        return globalCodeEnum;
    }

    public void setGlobalCodeEnum(GlobalCodeEnum globalCodeEnum) {
        this.globalCodeEnum = globalCodeEnum;
    }
}
